package com.yndsoft.jc.ui.memberpage.score;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.yndsoft.jc.R;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by hasee on 2017/12/7.
 */

public class ScoreDetailAdapter extends BaseAdapter {

    private List<String> datas = new ArrayList<>();
    private Context context;
    private LayoutInflater inflater;

    public ScoreDetailAdapter(Context context) {
        this.context = context;
        inflater = LayoutInflater.from(context);
    }

    public void setDatas(List<String> datas) {
        this.datas.clear();
        this.datas.addAll(datas);
        notifyDataSetChanged();
    }

    @Override
    public int getCount() {
        return datas.size();
    }

    @Override
    public Object getItem(int position) {
        return datas.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup viewGroup) {

        ScoreDetailViewHolder holder = null;
        if (convertView == null) {
            convertView = inflater.inflate(R.layout.item_score_detail_list, null);
            holder = new ScoreDetailViewHolder();
            holder.product_appraise_num = convertView.findViewById(R.id.product_appraise_num);
            convertView.setTag(holder);
        } else {
            holder = (ScoreDetailViewHolder) convertView.getTag();
        }
        holder.product_appraise_num.setText(datas.get(position));

        return convertView;
    }

    class ScoreDetailViewHolder {
        TextView product_appraise_num;
    }
}
